/***
 * keywords schema
 */
var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    ObjectId = require('mongoose').Types.ObjectId,
    keywordSchema;


var contentbank = mongoose.createConnection('mongodb://contentbank:ContentBank4.2@111.204.165.5:27017/contentbank');

// 完整的keywords
keywordSchema = new Schema({
    "title": String,
    "nicks": Array,
    "description": String
});

//statics
keywordSchema.statics = {
    findAllKeywords: function(callback){
        return this
            .find({'title':{$exists:true}},callback);
    },

    removeTitleLess : function() {
        this.remove({'title':{$exists:false}}, function(err, r){
            if(err){
                console.log(err);
            }
            console.log('Delete~~~~~~~~~~~~~~~~~~~~~~~~~~'+r);
        });
    }
};

exports.keywordSchema = keywordSchema;